package com.mydistibute.distibutelearn.threadstatus;

import java.io.IOException;

/**
 * @author victorydeng
 * @Classname SynchronizedDemo
 * @Description TODO
 * @Date 2020/5/26 22:45
 * @Created by victorydeng
 */
public class SynchronizedDemo  {
    static Integer count=0;
    public synchronized static void incr(){
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count++;
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        for(int i=0;i<1000;i++){
            new Thread(()->SynchronizedDemo.incr()).start();
        }
        Thread.sleep(5000);
        System.out.println("result:"+count);
    }
}